/**
 * Copyright (c) 快宝网络 kuaidihelp.com Co., Ltd. All Rights Reserved 禁止外泄以及用于其它的商业用途
 */

import request from '@/utils/request';

export async function getCustomersList(params: any) {
  return request('/jdk/gxdDkh/list', {
    method: 'POST',
    data: params,
  });
}

export async function getCustomersInfo(params: any) {
  return request('/jdk/gxdDkh/searchUser', {
    method: 'POST',
    data: params,
  });
}

export async function addCustomers(params: any) {
  return request('/jdk/gxdDkh/add', {
    method: 'POST',
    data: params,
  });
}

export async function removeCustomers(params: any) {
  return request('/jdk/gxdDkh/del', {
    method: 'POST',
    data: params,
  });
}

export async function getDeliveryAccountList(params: any) {
  return request('/jdk/gxdDkh/deliveryAccountList', {
    method: 'POST',
    data: { delivery_brand: 'gxd', ...params },
  }).then((res) => {
    const { data } = res;
    const list = data.map((item: any) => {
      const label = item.open_id + ' ' + item.account_remark;
      return {
        label,
        value: item.id,
      };
    });
    return list || [];
  });
}

export async function getAccountCityList() {
  return request('/jdk/gxdDkh/accountCityList', {
    method: 'POST',
    data: { delivery_brand: 'gxd' },
  }).then((res) => {
    const { data } = res;
    const list = data.map((item: any) => ({
      label: item.city,
      value: item.city,
    }));
    return list || [];
  });
}
